class Solution:
    def intersect(self, nums1: list, nums2: list) -> list:
        res = []
        for num in nums1:
            try:
                index = nums2.index(num)
            except:
                pass
            else:
                nums2[index] = "x"
                res.append(num)
        return res


a = Solution()
print(a.intersect(nums1=[1, 2, 2, 1], nums2=[2, 2]))
print(a.intersect(nums1=[4, 9, 5], nums2=[9, 4, 9, 8, 4]))
